package com.lwl.controller.sas;


import com.github.pagehelper.PageInfo;
import com.lwl.entity.LayData;
import com.lwl.entity.MyPage;

import com.lwl.entity.sas.TSasCallback;

import com.lwl.service.sas.TSasCallbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("tSasCallback")
public class TSasCallbackController {
    /**
     * 服务对象
     */
    @Autowired
    private TSasCallbackService tSasCallbackService;

    /**
     *  查询所有的回访记录
     * @return
     */
    @GetMapping("queryAll")
    public LayData queryAll(MyPage myPage, TSasCallback tSasCallback){
        PageInfo pageInfo = tSasCallbackService.queryAll(myPage,tSasCallback);
        return new LayData(pageInfo);
    }

    /**
     * 添加/修改回访记录
     * 添加/修改回访记录时要验证回访用户的id以及对应测试计划的id是否正确。
     * @return
     */
    @PostMapping("registerCallback")
    public LayData registerCallback(TSasCallback tSasCallback, HttpSession session){
        int insert = tSasCallbackService.insertCallback(tSasCallback,session);
        return new LayData(insert);
    }

}
